package com.example.fullexample.inlet.controller;

import com.example.fullexample.service.command.DeleteStudentCommand;
import com.example.fullexample.service.domain.Student;
import com.example.fullexample.service.query.StudentQuery;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentController {

    @GetMapping("/students/{id}")
    public Student getStudent(@PathVariable Long id) {
        StudentQuery query = new StudentQuery();
        return query.execute();
    }

    @PostMapping("/students/{id}/delete")
    public String deleteStudent(@PathVariable Long id) {
        DeleteStudentCommand command = new DeleteStudentCommand(id);
        command.execute();

        return "success";
    }
}
